package io.xxx.xbutler.domain;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler;
import io.xxx.xbutler.domain.task.ContentType;
import io.xxx.xbutler.domain.task.MessageType;
import io.xxx.xbutler.domain.task.SendStatus;
import lombok.Data;
import org.apache.ibatis.type.EnumTypeHandler;

import java.time.LocalDateTime;

@Data
public class RobotSendLog {

    @TableId
    private Long id;

    @TableField(typeHandler = EnumTypeHandler.class)
    private RobotType robotType;

    private String robotId;

    private String robotSerialNo;

    private String robotName;

    private String receiverType;

    private String receiverId;

    private String receiverSerialNo;

    private String receiverName;

    @TableField(typeHandler = EnumTypeHandler.class)
    private MessageType messageType;

    @TableField(typeHandler = EnumTypeHandler.class)
    private ContentType contentType;

    @TableField(typeHandler = Fastjson2TypeHandler.class)
    private JSONObject content;

    @TableField(typeHandler = EnumTypeHandler.class)
    private SendStatus status;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime pushStartTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime pushEndTime;

    /**
     * 推送耗时，从调用平台到收到回调的时间差
     */
    private Long pushElapsedTime;

    private Integer errorCode;

    private String errorMessage;

    @TableField(typeHandler = Fastjson2TypeHandler.class)
    private JSONObject extraData;

    private LocalDateTime createdTime;

    private LocalDateTime updatedTime;
}
